package com.io.stream.iobyte;

import com.io.stream.IoParam;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class IoByte02 {
    public static void main(String[] args) throws Exception {
        // 源文件 目标文件
        File source = new File(IoParam.BASE_PATH+"fileio-02.png") ;
        File target = new File(IoParam.BASE_PATH+"backup-"+source.getName()) ;
        // 缓冲：输入流 输出流
        InputStream bufInStream = new BufferedInputStream(new FileInputStream(source));
        OutputStream bufOutStream = new BufferedOutputStream(new FileOutputStream(target));
        // 读入 写出
        int readSign ;
        while ((readSign=bufInStream.read()) != -1){
            bufOutStream.write(readSign);
        }
        // 关闭输入、输出流
        bufOutStream.close();
        bufInStream.close();
    }
}
